#pragma warning disable CS8601 // Possible null reference assignment.

namespace Crux.Core.LangChain.Abstractions.ChatCompletion;
/// <summary>
/// 
/// </summary>
public class ChatHistoryMessage
{
    /// <summary>
    /// 
    /// </summary>
    public Role Role { get; set; } = Role.User;
    /// <summary>
    /// 
    /// </summary>
    public string Content { get; set; } = string.Empty;
    /// <summary>
    /// Creates a new <see cref="ChatHistoryMessage"/> from an <see cref="string"/>.
    /// </summary>
    /// <param name="value">The <see cref="string"/> to convert to a <see cref="ChatHistoryMessage"/>.</param>
    public static implicit operator ChatHistoryMessage(string? value)
    {
        if (string.IsNullOrEmpty(value)) return new ChatHistoryMessage();

        return new ChatHistoryMessage()
        {
            Content = value
        };
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="value"></param>
    public static implicit operator string?(ChatHistoryMessage value)
    {
        return value?.Content;
    }
}
#pragma warning restore CS8601 // Possible null reference assignment.
